//index.js
//获取应用实例
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    curTab: 0,
    current: 0,
    imgUrls: [{
        url: '../images/swip/1.jpg'
      }, {
        url: '../images/swip/2.jpg'
      }, {
        url: '../images/swip/3.jpg'
      },
      {
        url: '../images/swip/4.jpg'
      }
    ],
    titlenav: [{
        tit: "德云三宝"
      },
      {
        tit: "龄龙相声专场西安站"
      }, {
        tit: "高峰栾云平相声专场"
      }, {
        tit: "烧饼扬州相声专场"
      }
    ],
    heads: [{
        head: "../images/head/gdg.jpg",
        actorName: "郭德纲"
      },
      {
        head: "../images/head/gql.jpg",
        actorName: "郭麒麟"
      },
      {
        head: "../images/head/mht.jpg",
        actorName: "孟鹤堂"
      },
      {
        head: "../images/head/sjx.jpg",
        actorName: "尚九熙"
      },
      {
        head: "../images/head/ty.jpg",
        actorName: "陶阳"
      },
      {
        head: "../images/head/yyp.jpg",
        actorName: "岳云鹏"
      },
      {
        head: "../images/head/zhl.jpg",
        actorName: "张鹤伦"
      },
      {
        head: "../images/head/zjl.jpg",
        actorName: "张九龄"
      },
      {
        head: "../images/head/zyf.jpg",
        actorName: "烧饼"
      },
      {
        head: "../images/head/zyl.jpg",
        actorName: "张云雷"
      }
    ],
    nbFrontColor: '#000000',
    nbBackgroundColor: '#ffffff',
    indicatorDots: true, //小点
    autoplay: true, //是否自动轮播
    interval: 2000, //间隔时间
    duration: 800, //滑动时间
    goodsList: [],
    AllList: []
  },
  selectTab(e) {
    let index = e.target.dataset.index;
    this.setData({
      curTab: index,
      current: index
    })
  },
  // 点击搜索框跳转页面
  gosearch() {
    wx.navigateTo({
      url: "/pages/Search/Search"
    })
  },
  // 点击演出跳转详情页
  goCommodityDetails(e) {
    let self = this;
    let index = e.currentTarget.dataset.index
    wx.setStorage({
      key: 'ticId',
      data: self.data.AllList[index].ticId
    })
    wx.navigateTo({
      url: "/pages/CommodityDetails/CommodityDetails"
    })
  },
  // 点击跳转票兜
  goclip() {
    wx.navigateTo({
      url: "/pages/clip/clip"
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    // 登陆验证
    let userInfo = app.globalData.userInfo;
    if (userInfo == null) {
      wx.redirectTo({
        url: '/pages/Login/Login',
      })
    }
    let self = this;
    self.getAllList()

  },

//获取全部行程数据
getAllList: function() {
  let self = this;
  wx.request({
    url: "http://localhost:3000/showAllTickets",
    data: {},
    success(res) {
      let result = res.data;
      if (result) {
        //赋值
        self.setData({
          AllList: result
        })
      }
    }
  })
},

/**
 * 生命周期函数--监听页面初次渲染完成
 */
onReady: function() {

},

/**
 * 生命周期函数--监听页面显示
 */
onShow: function() {

},

/**
 * 生命周期函数--监听页面隐藏
 */
onHide: function() {

},

/**
 * 生命周期函数--监听页面卸载
 */
onUnload: function() {

},

/**
 * 页面相关事件处理函数--监听用户下拉动作
 */
onPullDownRefresh: function() {

},

/**
 * 页面上拉触底事件的处理函数
 */
onReachBottom: function() {

},

/**
 * 用户点击右上角分享
 */
onShareAppMessage: function() {

}
})